package com.ruoyi.insert.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.profession.domain.BasicInfo;
import com.ruoyi.profession.service.IBasicInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 人员基本信息Controller
 *
 */
@RestController
@RequestMapping("/insert/basicInfo")
public class IBasicInfoController extends BaseController
{
    @Autowired
    private IBasicInfoService basicInfoService;

    /**
     * 查询人员基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('profession:basicInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicInfo basicInfo)
    {
        startPage();
        List<BasicInfo> list = basicInfoService.selectBasicInfoList(basicInfo);
        return getDataTable(list);
    }

    /**
     * 导出人员基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('profession:basicInfo:export')")
    @Log(title = "人员基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicInfo basicInfo)
    {
        List<BasicInfo> list = basicInfoService.selectBasicInfoList(basicInfo);
        ExcelUtil<BasicInfo> util = new ExcelUtil<BasicInfo>(BasicInfo.class);
        util.exportExcel(response, list, "人员基本信息数据");
    }

    /**
     * 获取人员基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('profession:basicInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basicInfoService.selectBasicInfoById(id));
    }

    /**
     * 新增人员基本信息
     */
    @PreAuthorize("@ss.hasPermi('profession:basicInfo:add')")
    @Log(title = "人员基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicInfo basicInfo)
    {
        return toAjax(basicInfoService.insertBasicInfo(basicInfo));
    }

    /**
     * 修改人员基本信息
     */
    @PreAuthorize("@ss.hasPermi('profession:basicInfo:edit')")
    @Log(title = "人员基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicInfo basicInfo)
    {
        return toAjax(basicInfoService.updateBasicInfo(basicInfo));
    }

    /**
     * 删除人员基本信息
     */
    @PreAuthorize("@ss.hasPermi('profession:basicInfo:remove')")
    @Log(title = "人员基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basicInfoService.deleteBasicInfoByIds(ids));
    }
}
